package utils;

import engine.AlternateStateThreadPoolExecutor;
import entities.MMMEDirectory;

public class SimulatedUser{

	MMMEDirectory elemDir;
	
	private int counter = 0 ;
	private int delay = 1000;
	
	
	public SimulatedUser(MMMEDirectory elemDir) {
		super();
		this.elemDir = elemDir;
	}

	
	private void userBehaviour(){
		switch(counter){
			case 10 :
				elemDir.addUserMMME("userElement");
				System.out.println("User : userElement added");
				break;
			case 20 :
				elemDir.removeUserMMME("userElement");
				System.out.println("User : userElement removed");
				break;
			default:
				break;
		}
		counter++;
	}
	
	public void start() {
		
		Runnable me = new Runnable() {
			public synchronized void run() {
					try {
						SimulatedUser.this.userBehaviour();
						wait(delay);
						SimulatedUser.this.start();
					} catch (InterruptedException e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					}	
				}
		};
		
		AlternateStateThreadPoolExecutor.processExe.execute(me);
	}

}
